package com.woniu.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Data
//@ConfigurationProperties(prefix = "alipay.config")
@Configuration
public class AlipayConfiguration {
    private String serverUrl="MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCb7wdsCd6BP4slL1f2CqGvH9jyVKqvT94R/OdllAs2w0nc3KByAWz3LInr9m2uedsXeJQoNEDhEde26gOnwLDqtIysEFXNW/KgErLMW0DgaVvM9sY7PaKrJlKvGjA3gleoxQaSb6gUuFFOsLU3PEgfRggZRI5UZ+DlPJV3peBy1j4O9hIpoE7gJMX9HUvVhpBbDr0xbGU2Z+RNoc3XpTopB3s6JiAFyDGIQ3U9DoDTCQpALwgpemjBiwYRFWwLCWW3/8DU/C+rMPxlIyz7Y3QN5NOCUJ27+m/i2gZqaW459vAJyVhyaYU7FhsgUoyndSPcD0gvC27VOfL/ptynErCtAgMBAAECggEAHTCFhyfhyvgGKBPQt3IOCiZACjznJqIgw+U/u7gW0U2FSh7SugSiTTK9LrqWlY6iAKbFtTDy5C7e3pK31HMxqv3ZR2xXY3XO2UAm0DJU1q1iTd/0A6rqBHfMCpMwa3OuzRz0ufzEzfwi3EQf6BMUvSXy5if7LLm1U7QflqIqfdRqL9kkaiPNGaPjZ5ceI2u2OXHzuNkhQHFYPHzgZjAIjGvC8exN8WjfnsSsmj8SVm+oHNcMUvH8QNIhm9EcZURcVZx0v2jtjQcO+5YJO1Q8EScDM1FRe1Ws+pvlR8Tckynl/qbGsuSYDGDEhlNydarJoEIg93wrXZ9ywG3I1Msi0QKBgQDROXstzbDkdsEVhBK6MiI8oYF/C7aAmPJv4efeWC35lvKDcG6mZTUVJYuHBkeI+t6FQsxNDlhwwodf8SrD4yG9Fu3/fm3l6I9mdrsskN1qeKunylKfu7ggXPFDq2cWkTJ4a7s7hDBwMuatBgPjh184Nb9kxS6hPUKKvwXPna393wKBgQC+y4+rnXQ7I1aQGP/D6s2MIDcUBTklcBSzJsHuGTUBCoV/Y+ZjOMOAY6FoL1ryYy8j/PxflQhxorsln/wuUyBNBbd5zszJWAdAPJh6656sZwAnacVMyETO5CCv+Pm86CcFK2+TrCFQxo+8FPdAg+OFFf+7e0irVXdbkVUmsQAK8wKBgQCGuNSwcbpt4moCSMEmVBHnqLeR7yDdPZ8enACKE43HIYOXT1ZwnsrHix2FHG4DrkaK2LBlDc+1DA3PoaM/74lSEOm/ktGBMXblK57q2303iew+ZvE9Gcs+S5qvUDdZOLWfBP/TGxN1q9ENqMnoQMr3juRnJvEXsjKe1NIRFh9rUQKBgF7IJ0Y9ARnD02PgV2bPhW8gLdxvP9VeWZoqHdsXgKJUxL7lNPWDpHNqiyuDou2Y4jlBm2osUjaJfekSEig9OWWp+lyzpD490dRShflChd/lh0kNHWuoba5N3AMvb3kt5vyFeHdm4mILUipATBgrrOJXbGSJuS8MVTATAbcn5PqLAoGAdNIU/vrRIexdi3f2YWmO4wEXNH32HeHyWigSaFmGBYKumQZkKTuuGi0OnkZzSJz3xxWtE4173K5aR+5iG9ang0XsZO6BdQiAfnFMUKrAvMNKuNHQBJMBcfWCaW00Mkmhbio1CDbA1pkOixtao/P1aUkcmgjmU2tqaK4M99djHXA=";
    private String appid="https://openapi.alipaydev.com/gateway.do";
    private String privateKey="9021000135691608";
    private String alipayPublicKey="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm+8HbAnegT+LJS9X9gqhrx/Y8lSqr0/eEfznZZQLNsNJ3NygcgFs9yyJ6/ZtrnnbF3iUKDRA4RHXtuoDp8Cw6rSMrBBVzVvyoBKyzFtA4GlbzPbGOz2iqyZSrxowN4JXqMUGkm+oFLhRTrC1NzxIH0YIGUSOVGfg5TyVd6XgctY+DvYSKaBO4CTF/R1L1YaQWw69MWxlNmfkTaHN16U6KQd7OiYgBcgxiEN1PQ6A0wkKQC8IKXpowYsGERVsCwllt//A1PwvqzD8ZSMs+2N0DeTTglCdu/pv4toGamluOfbwCclYcmmFOxYbIFKMp3Uj3A9ILwtu1Tny/6bcpxKwrQIDAQAB";

    @Bean
    public AlipayClient config() throws Exception {
        AlipayConfig alipayConfig = new AlipayConfig();
        //设置网关地址
        alipayConfig.setPrivateKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCb7wdsCd6BP4slL1f2CqGvH9jyVKqvT94R/OdllAs2w0nc3KByAWz3LInr9m2uedsXeJQoNEDhEde26gOnwLDqtIysEFXNW/KgErLMW0DgaVvM9sY7PaKrJlKvGjA3gleoxQaSb6gUuFFOsLU3PEgfRggZRI5UZ+DlPJV3peBy1j4O9hIpoE7gJMX9HUvVhpBbDr0xbGU2Z+RNoc3XpTopB3s6JiAFyDGIQ3U9DoDTCQpALwgpemjBiwYRFWwLCWW3/8DU/C+rMPxlIyz7Y3QN5NOCUJ27+m/i2gZqaW459vAJyVhyaYU7FhsgUoyndSPcD0gvC27VOfL/ptynErCtAgMBAAECggEAHTCFhyfhyvgGKBPQt3IOCiZACjznJqIgw+U/u7gW0U2FSh7SugSiTTK9LrqWlY6iAKbFtTDy5C7e3pK31HMxqv3ZR2xXY3XO2UAm0DJU1q1iTd/0A6rqBHfMCpMwa3OuzRz0ufzEzfwi3EQf6BMUvSXy5if7LLm1U7QflqIqfdRqL9kkaiPNGaPjZ5ceI2u2OXHzuNkhQHFYPHzgZjAIjGvC8exN8WjfnsSsmj8SVm+oHNcMUvH8QNIhm9EcZURcVZx0v2jtjQcO+5YJO1Q8EScDM1FRe1Ws+pvlR8Tckynl/qbGsuSYDGDEhlNydarJoEIg93wrXZ9ywG3I1Msi0QKBgQDROXstzbDkdsEVhBK6MiI8oYF/C7aAmPJv4efeWC35lvKDcG6mZTUVJYuHBkeI+t6FQsxNDlhwwodf8SrD4yG9Fu3/fm3l6I9mdrsskN1qeKunylKfu7ggXPFDq2cWkTJ4a7s7hDBwMuatBgPjh184Nb9kxS6hPUKKvwXPna393wKBgQC+y4+rnXQ7I1aQGP/D6s2MIDcUBTklcBSzJsHuGTUBCoV/Y+ZjOMOAY6FoL1ryYy8j/PxflQhxorsln/wuUyBNBbd5zszJWAdAPJh6656sZwAnacVMyETO5CCv+Pm86CcFK2+TrCFQxo+8FPdAg+OFFf+7e0irVXdbkVUmsQAK8wKBgQCGuNSwcbpt4moCSMEmVBHnqLeR7yDdPZ8enACKE43HIYOXT1ZwnsrHix2FHG4DrkaK2LBlDc+1DA3PoaM/74lSEOm/ktGBMXblK57q2303iew+ZvE9Gcs+S5qvUDdZOLWfBP/TGxN1q9ENqMnoQMr3juRnJvEXsjKe1NIRFh9rUQKBgF7IJ0Y9ARnD02PgV2bPhW8gLdxvP9VeWZoqHdsXgKJUxL7lNPWDpHNqiyuDou2Y4jlBm2osUjaJfekSEig9OWWp+lyzpD490dRShflChd/lh0kNHWuoba5N3AMvb3kt5vyFeHdm4mILUipATBgrrOJXbGSJuS8MVTATAbcn5PqLAoGAdNIU/vrRIexdi3f2YWmO4wEXNH32HeHyWigSaFmGBYKumQZkKTuuGi0OnkZzSJz3xxWtE4173K5aR+5iG9ang0XsZO6BdQiAfnFMUKrAvMNKuNHQBJMBcfWCaW00Mkmhbio1CDbA1pkOixtao/P1aUkcmgjmU2tqaK4M99djHXA=");
        //设置应用ID
        alipayConfig.setServerUrl("https://openapi.alipaydev.com/gateway.do");
        //设置应用私钥
        alipayConfig.setAppId("9021000135691608");
        //设置支付宝公钥
        alipayConfig.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmz9FURzAlZNiqBTQzZDpH8Jmq2sa0/hBnG1nxwnmISX2b1o4zsVd4bfWHtNLRWlXtZF9aTLw/dcnD088gaIZXlLKt4cafjqkcgk/kH7Ms6jNw+fV/2AKHV46T0/1pcXsppH+TbaypTM3N8GPFLKICjyLW9sScDipCE6vHEitKkI+p8gfVS/n9oldrJzHngyfDXpB+eR9hu3LjKHrw/5iePI/42h8N2B0wVw+JeGrELYI+zlA6AHPYgix0ItB7Pk+vOtxGCI23JuhErKQtcHupDJXhFnrTV2wA4UDv+2sI+UYRxxNqZG5jtu/Ql3dsosEQtk8bzOdv5zp2DRqNJyiWwIDAQAB");
        //设置请求格式固定值json
        alipayConfig.setFormat("JSON");
        //设置字符集
        alipayConfig.setCharset("UTF-8");
        //设置签名类型
        alipayConfig.setSignType("RSA2");
        //实例化客户端
        AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
        return alipayClient;
    }
}